// 子模块moduleA路径：store/modules/moduleA.js 
export default {
  namespaced: true,
  state: {
    collectList: []
  },
  getters: {
    isCollect(state) {
      return (id) => {
        return state.collectList.some(v => v.id === id)
      }
    },
    collectCount(state) {
      return state.collectList.length
    }
  },
  mutations: {
    addCollect(state, payload) {
      state.collectList.unshift(payload)
    },
    cancelCollect(state, payload) {
      state.collectList = state.collectList.filter(v => v.id !== payload.id)
    }
  },
}
